<template>
    <el-container style="width: 100%; height: 100%; background-color: #ffffff">
        <el-header
            v-show="isShowFrontPage == 'true'"
            height="50px"
            class="header"
            style="background-color: #008cc8; padding: 0"
        >
            <div class="container">
                <div class="logo">
                    <img
                        :src="systemLogoUrl"
                        class="system-logo"
                        alt="系统LOGO"
                    />
                    {{ platformName }}
                </div>
            </div>
        </el-header>
        <el-main>
            <router-view></router-view>
        </el-main>
        <el-footer class="footer" height="80px">
            <div
                style="
                    display: flex;
                    justify-content: center;
                    align-items: center;
                "
            >
                <div
                    v-show="isShowFrontPage == 'true'"
                    style="color: #888888; margin-top: 30px"
                >
                    © FOREMOST. 上海爱可及医疗科技有限公司 V 1.0
                </div>
            </div>
        </el-footer>
    </el-container>
</template>

<script>
export default {
    name: "LayoutLogin",
    data() {
        return {
            ImageServiceURL: process.env.ImageServiceURL,
            systemLogoUrl: "/images/logo-now.png",
            platformName: "",
            isShowFrontPage: false,
        };
    },
    mounted() {
        this.getPlatform();
    },
    methods: {
        async getPlatform() {
            try {
                await this.$axios({
                    // 详见 axios 请求配置项
                    method: "GET",
                    url: "/PROXY-Remote/institutions/platform",
                }).then((res) => {
                    // 请求失败
                    if (res.data.code !== 200) {
                        throw new Error(res.data);
                    }
                    // 请求成功
                    const result = res.data.data;
                    this.platformName = result.name;
                    this.systemLogoUrl = this.ImageServiceURL + result.logoUrl;
                    this.isShowFrontPage = result.isShowFrontPage;
                    if (this.isShowFrontPage === "true") {
                        this.$router.push("/newLogin");
                    } else {
                        this.$router.push("/Login");
                    }
                });
            } catch (e) {
                // 跳出
            }
        },
    },
};
</script>

<style scoped>
.container {
    width: 1000px;

    margin: 0 auto;
}

.logo {
    height: 50px;

    font-size: 18px;
    color: #ffffff;

    line-height: 50px;
}

.logo img {
    vertical-align: middle;
}

.header {
    margin-top: 0;

    box-shadow: 0 1px 3px 1px rgba(26, 26, 26, 0.2);
}
</style>
